<template>
    <GFormCreator ref="createFrom" :conf="createConf" @submit="doSubmit">
        <!-- 自定义的按钮 -->
        <template #default>
            <div class="left">
                <el-button @click="doCreate" type="primary">创建管理员</el-button>
                <el-button @click="doReset">重置</el-button>
            </div>
        </template>
    </GFormCreator>
</template>

<script>
import createConf from "./createFormConf.js"
import { createUser } from "@/apis/user.js"
export default {
    name: "permission-create",
    data() {
        return {
            createConf
        };
    },
    methods: {
        doCreate() {
            // let res=this.$refs.createFrom.getData();
            // console.log("提交获取数据",res);
            this.$refs.createFrom.validate(async data => {
                if (data) {
                    console.log("验证通过", data);
                    let [res,err]=await createUser(data)
                    if(err) return this.$message.error("创建失败")
                    this.$message.success('创建成功');
                    //未完成跳转到用户列表
                } else {
                    console.log("验证失败");
                }
            })
        },
        doReset() {
            this.$refs.createFrom.reset();
        },
        doSubmit(data) {
            console.log("提交事件触发", data);
        }
    }
};
</script>

<style lang="" scoped>

</style>